﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class ScreenMain : MonoBehaviour
{
    public static ScreenMain Instance;

    public Transform parent;       // 父物体
    public GameObject Pixel;    // 像素点对象
    GameObject[,] _screen;      // 像素点数组


    int _ScreenWidth = 4;      // 屏幕宽度
    int _ScreenHeight = 8;     // 屏幕高度

    int _ScreenPoint_x = 0;    // 屏幕横坐标
    int _ScreenPoint_y = 0;    // 屏幕纵坐标
    int _PixelSize = 1;        // 像素点大小
    int _PixelInterval = 0;     // 像素点间距

    private void Awake()
    {
        Instance = this;
    }

    // 初始化
    public void Init()
    {
        // 遍历行
        for (int x = 0; x <= _ScreenWidth - 1; x++)
        {
            // 遍历列
            for (int y = 0; y <= _ScreenHeight - 1; y++)
            {
                // 计算坐标
                //int x = _ScreenPoint_x + list * (_PixelSize + _PixelInterval);
                //int y = _ScreenPoint_y + line * (_PixelSize + _PixelInterval);
                //Vector3 point = new Vector3(x, y, 0);

                Vector3 point = CellFunctions.GetPos(x, y);
                // 实例化像素点
                GameObject pixel = Instantiate(Pixel, point, Quaternion.identity, parent) as GameObject;
                pixel.transform.position = point;
            }
        }
    }

}
